package com.softaria.gwt.common.client.dialog;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.softaria.gwt.common.client.widget.Button;

public class YesNoDialog extends Dialog {

  public static interface YesNoListener {
    public void onYes();

    public void onNo();
  }

  private YesNoListener listener;

  public YesNoDialog(String yesLabel, String noLabel, String title, String message,
      YesNoListener myListener) {
    super(title, message);
    this.listener = myListener;

    addButton(new Button(yesLabel, new ClickHandler() {
      public void onClick(ClickEvent event) {
        listener.onYes();
        hide();
      }
    }));

    addButton(new Button(noLabel, new ClickHandler() {
      public void onClick(ClickEvent event) {
        listener.onNo();
        hide();
      }
    }));
  }

}
